#include <stdio.h>
#include <fcntl.h>
#include <pthread.h>
#include <mach/mach.h>
#include <sys/event.h>
#include <unistd.h>
#include "sys/event.h"
#include "private.h"


mach_port_t mach_task_self_=0xFFACFFAC;
mach_port_t bootstrap_port = 0xFFAC0000;

kern_return_t   mach_port_allocate
		(ipc_space_t                               task,
                 mach_port_right_t                        right,
                 mach_port_name_t                         *name)
{
	if(task!=mach_task_self_) return KERN_FAILURE;
	int port= kqueue();
	if(port <0) return KERN_FAILURE;
	*name=port;
	struct kqueue* q=kqueue_get(port);
	//FIXME:q->port_rights=right;
	return KERN_SUCCESS;
	
}

kern_return_t   mach_port_deallocate
                (ipc_space_t                               task,
                 mach_port_name_t                          name)
{
	if(task!=mach_task_self_) return KERN_FAILURE;
	close(name);
	return KERN_SUCCESS;
}


